package KEY;

import org.junit.jupiter.api.Test;

/**
 * @Author: Siantar
 * @Date: 2023-11-26-18:28
 * @Description: 1.0
 */
public class math {
    //返回满足 r^2 % n == 0的最小r;
    private int pSqrt(int n) {
        int res = 1;
        for (int i = 2; i * i <= n; i++) {
            int i2 = i * i;
            while (n % i2 == 0) {
                res *= i;
                n /= i2;
            }
            if (n % i == 0) {
                res *= i;
                n /= i;
            }
        }
        if (n > 1) {
            res *= n;
        }
        return res;
    }
    public int pow(int a, int b, int m) {
        long mark = a, res = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                res = (res * mark) % m;
            }
            mark = (mark * mark) % m;
            b >>= 1;
        }
        return (int) res;
    }
    @Test
    public void test() {
        System.out.println(pow(5,5,10));
    }
}
